<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    * {
        margin: 0;
        padding: 0;
    }

    .box {
        width: 80px;
        height: 80px;
        border: 1px solid #999;
    }

    .container {
        width: 5rem;
        height: 5rem;
        border: 1px solid #999;
    }
</style>

<body>
    <div class="box"></div>
    <div class="container">

    </div>
</body>
<script>
    (function fn(window, document) {
        let doc = document.documentElement

        function fun() {
            let rem = doc.clientWidth / 7.5
            doc.style.fontSize = rem + 'px'
        }
        fun()
        window.addEventListener('resize', fun)
        window.addEventListener('pageshow', function (e) {
            console.log('=-=-=',e);
            if (e.persisted) {
                fun()
            }
        })
    })(window, document)
</script>

</html>